import {Result} from '@/base/Result';
import {request} from '@/base/Request';
import {Page} from '@/base/Page';
import {Label} from '@/base/model/Label';
import {LabelSort} from '@/base/model/LabelSort';

import qs from 'qs'
import {DeviceModel} from "@/base/model/DeviceModel";



export function getLabelList(params: {
  pageIndex: number;
  pageSize: number;
  sortDirection: string;
  labelsortId?:number;
  labelname?:string;
  companyId?:[];
}): Promise<Result<Page<Label>>> {
  return request.getPage(Label, '/api/label?', {params});
}

export function getLabelSort(params: {
  pageIndex: number,
  pageSize: number,
  sortDirection: string
  sortProperties?:[];
  labelsortname?:string;
}) {
  return request.getPage(LabelSort, '/api/label-sort?', {params});
}

export function putLabelSort(params: {
  labelsortId: number,
  labelsortname: string,
}) {
  return request.put(LabelSort, '/api/label-sort/{labelsortId}'.replace('{labelsortId}', params.labelsortId.toString()), qs.stringify(params));
}

export function postLabelSort(params: {
  labelsortname: string,
}) {
  return request.post(LabelSort, '/api/label-sort', qs.stringify(params));
}

export function deleteLabelSort(params: {
  labelsortId: number
}) {
  return request.delete
  ('/api/label-sort/{labelsortId}'.replace
  ('{labelsortId}', params.labelsortId.toString()));
}

export function putLabelSortSort(params: {
  id: []
}) {
  return request.put(LabelSort, '/api/label-sort/sort', qs.stringify(params, {arrayFormat: 'repeat'}));
}

export function deleteLabel(params: {
  labelsortId: number
}) {
  return request.delete('/api/label/{labelsortId}'.replace('{labelsortId}', params.labelsortId.toString()));
}

export function getLabel(params: {
  labelId: number
}) {
  return request.get(Label, '/api/label/{labelId}'.replace('{labelId}', params.labelId.toString()));
}
export function
putLabel(params: {
  labelId: number,
  companyId: number,
  labelsortId: number,
  labelname: string,
  sort: number
}) {
  return request.put(Label, '/api/label/{labelId}'.replace('{labelId}', params.labelId.toString()), qs.stringify(params));
}

export function postLabel(params: {
  labelname :string,
  companyId: number,
  labelsortId: number,
}) {
  return request.post(Label, '/api/label', qs.stringify(params));
}
